{% extends "admin/base_site.html" %}
{% load staticfiles %}
<!-- LOADING -->
{% load i18n admin_urls %}

{% block extrahead %}
<link href="{% static 'admin/css/history.css' %}" type="text/css" rel="stylesheet"/>
{% endblock %}

<!-- BREADCRUMBS -->
{% block breadcrumbs %}
    <ul class="grp-horizontal-list">
        <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
        <li><a href="{% url 'admin:app_list' app_label=app_label %}">{% trans app_label|capfirst|escape %}</a></li>
        <li><a href="{% url opts|admin_urlname:'changelist' %}">{{ module_name }}</a></li>
        <li><a href="{% url opts|admin_urlname:'changelist' %}{{ object.pk }}">{{ object|truncatewords:"18" }}</a></li>
        <li>{% trans 'History' %}</li>
    </ul>
{% endblock %}

<!-- CONTENT -->
{% block content %}
    <div id="grp-content-container">

        <div class="g-d-c grp-object-history">

            <table id="grp-change-history">
                <thead>
                <tr>
                    <th scope="col" rowspan="2">Дата и время</th>
                    <th scope="col" rowspan="2">Пользователь</th>
                    <th scope="col" colspan="3" style="text-align: center">Действие</th>
                </tr>
                <tr>
                    <th scope="col" class="history-head">Поле</th>
                    <th scope="col">До</th>
                    <th scope="col">После</th>
                </tr>
                </thead>
                <tbody>


                {% for changeset in changesets %}
                    <tr class="changeset-{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
                        {% with changeset.changes.all as changes %}
                            <td rowspan="{{ changes|length }}">
                                {{ changeset.date }}

                            </td>
                            <td rowspan="{{ changes|length }}">
                                {{ changeset.author }}
                            </td>
                            {% if changeset.initial %}
                                <td colspan="3" style="text-align: center; font-weight: bold">
                                    Услуга создана
                                </td>
                            {% else %}
                                {% for change in changes %}
                                    <td class="history-cell">
                                        {{ change.field }}
                                    </td>
                                    <td class="history-cell">
                                        {{ change.old }}
                                    </td>
                                    <td class="history-cell">
                                        {{ change.value }}
                                    </td>
                                    {% if changes|length > 1 %}
                                        </tr><tr class="changeset-{% if forloop.parentloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
                                    {% endif %}
                                {% endfor %}
                            {% endif %}
                        {% endwith %}
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}